class ZlibExample {
	public constructor() {
	}

	public test(): void {
		let gameList = RES.getGroupByName("game");
        let zipName = "zlibgame_cfg";
		RES.getResAsync(zipName, (data) => {
			this.parseCfg(gameList, zipName);
		}, this)
	}

	private parseCfg(groupList: Array<any>, zipName: string): void
    {
        let idx = 0;
        let data = RES.getRes(zipName);

        let plain = new Uint8Array(data);  //data is a ArrayBuffer
        let inflate = new Zlib.Inflate(plain);
        let deplain = inflate.decompress();
        let lastbytes = deplain.buffer;
        //egret 将二进制解析成object
        let bytes: egret.ByteArray = new egret.ByteArray(lastbytes);
        let obj = JSON.parse(bytes.readUTFBytes(lastbytes.byteLength));

        for (let i = 0; i < groupList.length; i++)
        {
            let groupObj = groupList[i];
            let url = groupObj.url;
            let key = String(groupObj.name).toLocaleLowerCase();
            let txt = obj[key];
			console.log(txt);
        }
    }

	private static instance: ZlibExample;
    public static getIt(): ZlibExample
    {
        if (!this.instance)
            this.instance = new ZlibExample();

        return this.instance;
    }
}